<template>
  <div style="width:70%;margin:0px auto;">
    <a-form :form="form" @submit="handleSubmit">
      <a-row>
        <a-col style="margin-top:80px;margin-bottom:30px;" :xs="{ span : 24 }" :sm="{ span:24 }" class="formGroupTitle">
          我们已向您填写的手机号{{ this.$route.params.mobileNo }}发送了一条验证码，请查收后填写</a-col>
      </a-row>
      <a-form-item v-bind="formItemLayout" label="验证码">
        <a-input placeholder="请输入短信验证码" v-decorator="[
                        'VerCode',
                        {
                            rules: [{
                            required: true, message: '请输入短信验证码',
                            },{validator: validateverCode}],validateTrigger: 'blur'
                        }
                        ]" />
      </a-form-item>
      <a-row>
        <a-col :sm="{ span:5 }"></a-col>
          <a-col :xs="{ span : 24 }" :sm="{ span:10,offset:1 }" >
              <a-button type="primary" html-type="submit" :loading="loading">下一步</a-button></a-col>
        </a-row>
    </a-form>
  </div>
</template>

<script>
  import AForm from "ant-design-vue/es/form/Form";
  import ATabs from "ant-design-vue/es/tabs";
  import GlobalFooter from "../../../layouts/GlobalFooter";
  import AFormItem from "ant-design-vue/es/form/FormItem";
  import AInput from "ant-design-vue/es/input/Input";
  import AIcon from "ant-design-vue/es/icon";
  import AInputGroup from "ant-design-vue/es/input/Group";
  import AButton from "ant-design-vue/es/button/button";
  import ACol from "ant-design-vue/es/grid/Col";
  import ARow from "ant-design-vue/es/grid/Row";
  import ACheckbox from "ant-design-vue/es/checkbox/Checkbox";
  import AAlert from "ant-design-vue/es/alert/index";

  const ATabPane = ATabs.TabPane;

  export default {
    name: "Login",
    components: {
      AAlert,
      ACheckbox,
      ACol,
      ARow,
      AButton,
      AInputGroup,
      AIcon,
      AInput,
      AFormItem,
      GlobalFooter,
      ATabPane,
      ATabs,
      AForm
    },
    data() {
      return {
        formItemLayout: {
          labelCol: {
            xs: { span: 24 },
            sm: { span: 5 }
          },
          wrapperCol: {
            xs: { span: 24 },
            sm: { span: 12,offset:1 },
            md: { span: 10,offset:1 }
          }
        },
        form: this.$form.createForm(this),
        isSpe: false,
        code: null,
      };
    },
    watch: {},
    computed: {},
    mounted() { },
    methods: {
      handleChange(value) {
        console.log(value);
      },
      handleSubmit(e) {
        e.preventDefault();
        this.form.validateFields((err, values) => {
          if (!err) {
            this.loading = true;
            let data = {
              code:values.VerCode,
              accountNo:this.$route.params.accountNo
            }
            this.$axios.post("/agent/binding/bankCard/insert",data).then(res => {
              console.log(res.data);
              // if(res.data.code == "OK"){
                this.loading=false;
                this.$router.push({ path: "/per/bankadd/addbankres", query: { isok: 'true' } });
              // }else{
                // this.$router.push({ path: "/per/bankadd/addbankres", query: { isok: 'false' } });
              // }

            });
          }
        });
      },
      validateverCode(rule, value, callback) {
        const reg = new RegExp("^[0-9]{4,10}$");
        if (value && !reg.test(value)) {
          callback("您输入的验证码格式有误！");
        } else {
          this.verCode = value;
        }
        callback();
      }
    }
  };
</script>

<style scoped>
  /* @import " ../../../../static/css/color.css"; */
  span {
    cursor: pointer;
  }

  li {
    list-style: none;
  }

  .formGroupTitle {
    font-size: 18px;
    font-weight: 500;
    text-align: left;
  }
</style>
